// pages/alarm/alarm.js
const app = getApp()
var util = require('../../utils/util.js');
Page({
    /**
     * 页面的初始数据
     */
    data: {
        time1: '12:01',
        time2: '12:01',
        time3: '12:01',
        array: ['每天','周一', '周二', '周三', '周四','周五','周六','周日'],
        index1: 0,
        index2: 0,
        index3: 0,
        switch1Checked: false,
        switch2Checked: false,
        switch3Checked: false,
    },
    
    switch1Change:function(c1){
      console.log(`switch1发生change事件，携带值为`, c1.detail.value)
      var obj1 = {}
      obj1[`switch1Checked`] = c1.detail.value
      this.setData(obj1)
      obj1 = {}
      obj1[`switch1Style`] = c1.detail.value ? '' : 'text-decoration: line-through'
      this.setData(obj1)
    },
    switch2Change:function(c2){
      console.log(`switch2发生change事件，携带值为`, c2.detail.value)
      var obj2 = {}
      obj2[`switch2Checked`] = c2.detail.value
      this.setData(obj2)
      obj2 = {}
      obj2[`switch2Style`] = c2.detail.value ? '' : 'text-decoration: line-through'
      this.setData(obj2)
    },
    switch3Change:function(c3){
      console.log(`switch3发生change事件，携带值为`, c3.detail.value)
      var obj3 = {}
      obj3[`switch3Checked`] = c3.detail.value
      this.setData(obj3)
      obj3 = {}
      obj3[`switch3Style`] = c3.detail.value ? '' : 'text-decoration: line-through'
      this.setData(obj3)
    },
    bindTimeChange1: function(e1) {
        this.setData({
          time1: e1.detail.value
        })
      },
    bindTimeChange2: function(e2) {
        this.setData({
          time2: e2.detail.value
        })
      },
      bindTimeChange3: function(e3) {
        this.setData({
          time3: e3.detail.value
        })
      },
      bindDateChange1:function(e4){
        this.setData({
          index1: e4.detail.value
        })
      },
      bindDateChange2:function(e5){
        this.setData({
          index2: e5.detail.value
        })
      },
      bindDateChange3:function(e6){
        this.setData({
          index3: e6.detail.value
        })
      },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },


    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    toHome:function(){
      wx.request({
        url: 'http://82.157.94.115:2005/alarm',
        method: 'POST',
        header: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        data: {
          time1: this.data.time1,
          time2: this.data.time2,
          time3: this.data.time3,
          index1: this.data.index1,
          index2: this.data.index2,
          index3: this.data.index3,
          switch1Checked: this.data.switch1Checked,
          switch2Checked: this.data.switch2Checked,
          switch3Checked: this.data.switch3Checked,
        },
        success:function(){
          wx.switchTab({
            url: '/pages/home/home',
          })
        }
      })

    },
    uploadFormId(e){
      //上传form_id 发模板消息
      wx.request({
          url: 'xx/xx/uploadFormId',
          data: {
              form_id: e.detail.formId
          }
      });
  }
})